using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace DNNToolkit.Modules.CityTaxLocator.Components
{
    public class StateItem
    {
        private string mBlockData;
        private long mRowNum;
        private string mStateName;

        protected internal StateItem(string strBlockData, long rowNum, string stateName)
        {
            mBlockData = strBlockData;
            mRowNum = rowNum;
            mStateName = stateName;
        }

        public IEnumerable<CityItem> Items()
        {
            StringReader reader = new StringReader(mBlockData);

            for (long i = 0; i < mRowNum; i++)
            {
                string line1 = reader.ReadLine();
                if (line1 == null)
                    throw new FileFormatException();
                string line2 = reader.ReadLine();
                if (line2 == null)
                    throw new FileFormatException();
                string line3 = reader.ReadLine();
                if (line3 == null)
                    throw new FileFormatException();

                yield return new CityItem(line1, line2, line3,mStateName);
            }
        }
    }
}
